#include "ros/ros.h"
#include "tf2_ros/transform_listener.h"
#include "geometry_msgs/TransformStamped.h"

int main(int argc, char *argv[])
{
        setlocale(LC_ALL,"");
    // 2.初始化 ROS 节点
        ros::init(argc,argv,"cal_tf");

        ros::NodeHandle nd;
        tf2_ros::Buffer buff;

        tf2_ros::TransformListener listener(buff);

        ros::Rate r(10);

        while (ros::ok())
        {
                try
                {
                        geometry_msgs::TransformStamped  tfs;
                        tfs = buff.lookupTransform("son2","son1",ros::Time(0));

                        ROS_INFO("%.2f",tfs.transform.translation.x);
                }
                catch(const std::exception& e)
                {
                        ROS_INFO("error info : %s",e.what()) ;
                }
                
                r.sleep();
        }
        return 0;
}